﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/SiteTemplate.Master" AutoEventWireup="True"
    CodeBehind="Index.aspx.cs" Inherits="LoveMusic.ArtistDetailView" %>

<%@ Import Namespace="LoveMusic" %>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <% var artist = ((ArtistDetailData)ViewData.Model).Artist; %>
    <title>
        <%=Server.HtmlEncode(artist.Name)%>
        - all songs continues video & mp3 play - Listen on IloveThisMusic.com</title>
    <meta name="description" content="Listen continues youtube and mp3 play from artist  <%=Server.HtmlEncode(artist.Name)%> free in your web browser." />
    <meta name="keywords" content="<%=Server.HtmlEncode(artist.Name)%>,<%=Server.HtmlEncode(artist.Name)%>, <%=Server.HtmlEncode(artist.Name) %>,ilovethismusic,song,music,watch,listen,share,rate,download,new music" />
    <script type="text/javascript" src="/cache/cachecontent/JavaScriptIncludeArtist/1/javascript"
        temp_src="/cache/cachecontent/JavaScriptIncludeArtist/1/javascript"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% var artist = ((ArtistDetailData)ViewData.Model).Artist; %>
    <% if (artist == null) %>
    <% { %>
    <span class="pageMessage">The artist does not exists.</span>
    <% } %>
    <% else %>
    <% { %>
    <script type="text/javascript">
      $(function() {
    // Tabs
    $('#tabs').tabs();
});

$(function() {
            $('#slideshow2').cycle(
                {
                        prev: '#prev',next: '#next',timeout: 5000
                }
                                   );
            });
            
        // YouTube JavaScript Player With Playlist
        // http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
        // Revision 1 [2009-10-12]
        //
        // Prerequisites
        // 1) Create following elements in your HTML:
        // -- a) ytplayer: a named anchor
        // -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
        // -- c) ytplayer_div2: container div for playlist
        // 2) Include SWFObject library from http://code.google.com/p/swfobject/
        //
        // Variables
        // -- ytplayer_playlist: an array containing YouTube Video IDs
        // -- ytplayer_playitem: index of the video to be played at any given time
        //
 var limitCounterSongs=1;
        var currentAddedSongNumber=0;
        var ytplayer_playlist = [];
        var ytplayer_playitem = 0;
        swfobject.addLoadEvent(ytplayer_render_player);
        swfobject.addLoadEvent(ytplayer_render_playlist);
        function ytplayer_render_player() {
            swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ytplayer_playitem] + '&enablejsapi=1&rel=0&fs=1&showinfo=1&iv_load_policy=3',
      'ytplayer_div1',
      '425',
      '344',
      '8',
      null,
      null,
      {
          allowScriptAccess: 'always',
          allowFullScreen: 'true'
      },
      {
          id: 'ytplayer_object'
      }
    );
        }
        
        function ytplayer_addOneSong(start){
                var link = document.createElement("img");
                var img = document.createElement("img");
                img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[start] + "/default.jpg";
                
                var a = document.createElement("a");
                a.setAttribute('id','image-'+start);
                a.setAttribute("class", "copy");
                
                a.href = "#ytplayer";
                a.onclick = (
                                function(j) {
                                                return function() 
                                                {
                                                    ytplayer_playitem = j;
                                                    ytplayer_playlazy(1000);
                                                };
                                            }
                              )(start);
                a.appendChild(img);
                document.getElementById("ytplayer_div2").appendChild(a);
                
                if (currentAddedSongNumber < start)
                    currentAddedSongNumber =start;
        }
        
        function ytplayer_removeOneSong(start){
                var a = document.getElementById('image-'+start);
                if (a)
                    document.getElementById("ytplayer_div2").removeChild(a);
        }
        
        
        function ytplayer_render_playlist() {
            var i=1;
            var counterReached =0;
            while (counterReached<2) 
            {
                if (ytplayer_playlist[i]!='')
                {
                    ytplayer_addOneSong(i);
                    counterReached++;
                }
                i++;
            }
        }
        function ytplayer_playlazy(delay) {
            //
            // Thanks to the anonymous person posted this tip:
            // http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
            //
            if (typeof ytplayer_playlazy.timeoutid != 'undefined') {
                window.clearTimeout(ytplayer_playlazy.timeoutid);
            }
            ytplayer_playlazy.timeoutid = window.setTimeout(ytplayer_play, delay);
        }
        
        function ytplayer_play() {
        
            var o = document.getElementById('ytplayer_object');
            var breakReached= false;
            if (o) {
                if (ytplayer_playlist[ytplayer_playitem]!='')
                {
                    o.loadVideoById(ytplayer_playlist[ytplayer_playitem]);
                
              
              
                    // Add song only if it's a new song
                    if (ytplayer_playitem+1>currentAddedSongNumber)
                    {
                         while (!breakReached)
                         {
                                if (ytplayer_playlist[ytplayer_playitem+1] != '')
                                {
                                    ytplayer_addOneSong(ytplayer_playitem+1);
                                    // If limit reached remove song starting from first
                                    if (ytplayer_playitem > limitCounterSongs)
                                        ytplayer_removeOneSong(ytplayer_playitem - limitCounterSongs-1);
                                    
                                    breakReached = true;
                                }
                                else
                                {
                                    ytplayer_playitem++;
                                    limitCounterSongs++;
                                }
                          }
                    }
                 }
                 else
                 {
                                    ytplayer_playitem++;
                 }
            }
        }
        //
        // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
        // * Sets up handler for other events
        //
        function onYouTubePlayerReady(playerid) {
            var o = document.getElementById('ytplayer_object');
            if (o) {
                o.addEventListener("onStateChange", "ytplayer_statechange");
                o.addEventListener("onError", "ytplayer_error");
            }
        }
        //
        // State Change Handler
        // * Sets up the video index variable
        // * Calls the lazy play function
        //
        function ytplayer_statechange(state) {
            if (state == 0) {
                ytplayer_playitem += 1;
                ytplayer_playitem %= ytplayer_playlist.length;
                ytplayer_playlazy(5000);
            }
        }
        //
        // Error Handler
        // * Sets up the video index variable
        // * Calls the lazy play function
        //
        function ytplayer_error(error) {
            if (error) {
                ytplayer_playitem += 1;
                ytplayer_playitem %= ytplayer_playlist.length;
                ytplayer_playlazy(5000);
            }
        }
        //
        // Add items to the playlist one-by-one
        //
        <% if (artist.PlayListYouTube!=null) %>
        <% foreach (string youTubeID in artist.PlayListYouTube) %>
        <% { %>
            ytplayer_playlist.push('<%= youTubeID  %>');
        <% } %> 
    </script>
    <div id="artistHolder" style="padding-top: 3px;margin:10px;" >
        <h2 class="demoHeaders" style="margin-top: 0px">
            <%= Server.HtmlEncode(artist.Name)%>
        </h2>
        <%= Server.HtmlEncode(artist.RealName)%>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-listen">Listen audio</a></li>
                <li><a href="#tabs-watch">Watch video</a></li>
                <li><a href="#tabs-similar">Similar Artists</a></li>
                <li><a href="#tabs-reviews">Reviews</a></li>
                <li><a href="#tabs-blogs">Blogs</a></li>
                <li><a href="#tabs-allsongs">All songs</a></li>
                <li><a href="#tabs-bio">Bio</a></li>
                <li><a href="#tabs-download">Download</a></li>
                <%-- <li><a href="#tabs-styles">Styles</a></li>--%>
            </ul>
            <div id="tabs-listen">
                <div id="sliki" class="sliki" style="float: left; margin-right: 20px;">
                    <div class="count_detail">
                        <div id="slideshow2">
                            <% int imageCount = 0; %>
                            <% foreach (var imageID in artist.Images) %>
                            <% { %>
                            <%if (imageID != 0) %>
                            <%{ %>
                            <%=  Html.Image(Url.Content("~/Song/Image/" + imageID + "/250/250"),"image "+artist.Name, new { width = "250", height = "250" })%>
                            <%} %>
                            <%  else %>
                            <% {%>
                            <%= Html.Image(Url.Content("~/Views/Images/error.gif"), "image " + artist.Name, new { width = "250", height = "250" })%>
                            <%} %>
                            <% if (++imageCount == 4) break; %>
                            <%}%>
                        </div>
                    </div>
                    <div style="text-align: right;">
                        <a href="#" class="copy" id="prev">prev</a> <a href="#" class="copy" id="next">next</a>
                    </div>
                    <div style="display: inline; padding: 10px; margin-left: 25px; margin-top: 10px;"
                        class="removeDots">
                        <ul>
                            <li><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">
                                Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
                            </li>
                            <li>
                                <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>
                            </li>
                            <li>
                                <script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script>
                            </li>
                            <li>
                                <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
                            </li>
                        </ul>
                    </div>
                </div>
                <div>
                    <object type="application/x-shockwave-flash" data="/player_mp3_multi.swf" width="400"
                        height="300">
                        <param name="movie" value="/player_mp3_multi.swf" />
                        <param name="bgcolor" value="#000024" />
                        <%if (artist.Mp3Songs != null)
                          { %>
                        <param name="FlashVars" value="mp3=<%= artist.Mp3Songs.Url %>&amp;title=<%=artist.Mp3Songs.Title %>&amp;width=400&amp;height=300&amp;showvolume=1&amp;autoplay=1&amp;buttonwidth=36&amp;sliderwidth=40&amp;sliderheight=12&amp;volumewidth=45&amp;volumeheight=13&amp;loadingcolor=0f1cff&amp;bgcolor=000024&amp;bgcolor1=360000&amp;bgcolor2=000000&amp;slidercolor1=900203&amp;slidercolor2=ed0103&amp;sliderovercolor=fffff0&amp;buttoncolor=ed0103&amp;buttonovercolor=fffffa&amp;playlistalpha=75&amp;currentmp3color=ff0000&amp;scrollbarcolor=fb0000&amp;scrollbarovercolor=ffffff" />
                        <p>
                            You must have flash enabled
                        </p>
                        <%} %>
                    </object>
                </div>
                <br />
                <br />
                <h2 class="title">
                    <%=artist.Name %>
                    overview</h2>
                <br />
                <div id="somethis" class="removeDots">
                    <div class="description">
                        <div class="description">
                            <div class="NewsContainer">
                                <ul>
                                    <% if (artist.Bios.Count > 0) %>
                                    <% { %>
                                    <li>
                                        <div class="ContainerDiv">
                                            <div class="NewsText">
                                                <%=artist.Bios[0].Text%>
                                                <a href="<%= artist.Bios[0].SourceUrl %>" style="font-size: smaller" target="_blank">
                                                    read more</a>
                                            </div>
                                        </div>
                                    </li>
                                    <%} %>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="tabs-watch">
                <div id="divPlayer" style="float: left;">
                    <a name="ytplayer"></a>
                    <div id="ytplayer_div1">
                        You need Flash player 8+ and JavaScript enabled to view this video.</div>
                </div>
                <div id="ytplayer_div2" style="position: relative; width: 150px; height: 400px; overflow: auto;">
                    <h3 class="title" style="margin-left: 25px; font-weight: bold; font-size: larger;">
                        NEXT</h3>
                </div>
            </div>
            <div id="tabs-similar" class="removeDots">
                <% if (artist.SimilarArtists != null && artist.SimilarArtists.Count > 0) %>
                <%  { %>
                <div class="description">
                    <ul>
                        <% foreach (string artistName in artist.SimilarArtists) %>
                        <% { %>
                        <li>
                            <%--  <%= Html.ActionLink<ArtistController>(c => c.SimilarArtist(artistName), artistName)%>--%>
                            <%=Html.ActionLink(Server.HtmlDecode(artistName), "Index", "Artist", new { artistName = artistName }, null)%>
                        </li>
                        <%} %>
                    </ul>
                </div>
                <%} %></div>
            <div id="tabs-reviews" class="removeDots">
                <% if (artist.Reviews != null && artist.Reviews.Count > 0) %>
                <%  { %>
                <div class="descriptionText">
                    <ul>
                        <% foreach (var review in artist.Reviews) %>
                        <% { %>
                        <li>
                            <div class="NewsContainer">
                                   <div class="description" style="margin-bottom:10px;"  >
                                        <a style="font-size:22px; color: #DA4406;" href="<%=review.Url%>" target="_blank"><%=Html.Encode(review.Name)%></a>
                                    </div>
                              
                                <div class="ContainerDiv">
                                    <div class="RealeseImage">
                                        <%if (review.ImageUrl != null && review.ImageUrl != string.Empty)%>
                                        <% { %>
                                        <%= Html.Image(review.ImageUrl,"review image",null)%>
                                        <% } %>
                                        <br />
                                        <%=Html.Encode(review.ReleaseName)%>
                                    </div>
                                    <div class="NewsText">
                                        <%=review.Summary%>
                                        <a href="<%=review.Url %>" style="font-size: smaller" target="_blank">read more</a>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <%} %>
                    </ul>
                </div>
                <%} %>
            </div>
            <div id="tabs-blogs" class="removeDots">
                <% if (artist.Blogs != null && artist.Blogs.Count > 0) %>
                <%  { %>
                <div class="description">
                    <ul>
                        <% foreach (var blog in artist.Blogs) %>
                        <% { %>
                        <li>
                            <div class="NewsContainer">
                                <div class="NewsTitle">
                                    <h4>
                                        <a href="<%=blog.Url %>" class="copyNewsLinks" target="_blank">
                                            <%=Html.Encode(blog.Name) %></a></h4>
                                </div>
                                <div class="NewsText">
                                    <%=blog.Summary %><a href="<%=blog.Url %>" style="font-size: smaller" target="_blank">read
                                        more</a></div>
                            </div>
                        </li>
                        <%} %>
                    </ul>
                </div>
                <%} %>
            </div>
            <div id="tabs-allsongs" class="removeDots">
                <div class="description">
                    <div class="label_detail">
                        All songs by :
                        <%= Server.HtmlEncode(artist.Name)%>
                    </div>
                    <div>
                        <%foreach (var song in artist.Songs) %>
                        <%{ %>
                        <%--<%= Html.ActionLink<SongController>(c => c.Detail(song.StoryID), Html.Encode(song.Title))%>--%>
                        <%=Html.ActionLink(Server.HtmlDecode(song.Title), "Detail", "Song", new { id = song.StoryID }, null)%>
                        <br />
                        <%} %>
                    </div>
                </div>
            </div>
            <div id="tabs-bio" class="removeDots">
                <div class="description">
                    <div class="description">
                        <div class="NewsContainer">
                            <ul>
                                <% foreach (var bio in artist.Bios) %>
                                <% { %>
                                <li>
                                    <div class="ContainerDiv">
                                        <div class="NewsText">
                                            <%=bio.Text%>
                                            <a href="<%= bio.SourceUrl %>" style="font-size: smaller" target="_blank">read more</a>
                                        </div>
                                    </div>
                                </li>
                                <br />
                                <br />
                                <%} %>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div id="tabs-download">
                <ol>
                    <% foreach (var story in artist.Songs)
                       {  %>
                    <div style="padding-left: 25px;">
                        <li><a target="_blank" href="<%=story.url%>">
                            <%=Server.HtmlDecode(story.Title)%></a></li>
                    </div>
                    <%} %>
                </ol>
            </div>
            <%--   <div id="tabs-styles" class="removeDots">
                                <% if (artist.NameVariations != null && artist.NameVariations.Length > 0) %>
                                <%  { %>
                                <div class="description">
                                    <div class="label_detail">
                                        Name variations:</div>
                                    <br />
                                    <% foreach (string bio in artist.NameVariations) %>
                                    <% { %>
                                    <%= Html.Encode(bio)%>
                                    <br />
                                    <%} %>
                                </div>
                                <%} %>
                                <% if (artist.Aliases != null && artist.Aliases.Length > 0) %>
                                <%  { %>
                                <div class="description">
                                    <div class="label_detail">
                                        Aliases:</div>
                                    <br />
                                    <% foreach (string alias in artist.Aliases) %>
                                    <% { %>
                                    <%= Html.Encode(alias)%>
                                    <br />
                                    <%} %>
                                </div>
                                <%} %>
                                <% if (artist.Urls != null && artist.Urls.Length > 0) %>
                                <%  { %>
                                <div class="description">
                                    <div class="label_detail">
                                        Urls:</div>
                                    <br />
                                    <% foreach (string url in artist.Urls) %>
                                    <% { %>
                                    <%= Html.Encode(url)%>
                                    <br />
                                    <%} %>
                                </div>
                                <%} %>
                                <% if (artist.Styles != null && artist.Styles.Count > 0) %>
                                <%  { %>
                                <div class="description">
                                    <div class="label_detail">
                                        Styles:</div>
                                    <br />
                                    <ul>
                                        <% foreach (string style in artist.Styles) %>
                                        <% { %>
                                        <li>
                                            <%= Html.Encode(style)%></li>
                                        <%} %>
                                    </ul>
                                </div>
                                <%} %>
                                <% if (artist.Moods != null && artist.Moods.Count > 0) %>
                                <%  { %>
                                <div class="description">
                                    <div class="label_detail">
                                        Moods:</div>
                                    <br />
                                    <ul>
                                        <% foreach (string mood in artist.Moods) %>
                                        <% { %>
                                        <li>
                                            <%= Html.Encode(mood)%></li>
                                        <%} %>
                                    </ul>
                                </div>
                                <%} %>
                                <div class="description">
                                    Born:
                                    <%=Html.Encode(artist.Born) %>
                                    Died:
                                    <%=Html.Encode(artist.Died) %>
                                    Familiarity:
                                    <%=Html.Encode(artist.Familiarity) %>
                                    Hotness:<%=Html.Encode(artist.Hotness) %>
                                </div>
                                <div class="summary">
                                    <span class="category">category:</span>
                                    <%= Html.ActionLink<SongController>(c => c.Category(artist.Category.UrlEncode(), 1), artist.Category)%>
                                </div>
                             
                            </div>--%>
        </div>
    </div>
    <% } %>
</asp:Content>
